//对电影院数组按照距离排序
function sortarr(arr, asc_or_desc) {
    //desc_or_asc 0为升序，1为降序,这个方法不会修改原数组
    var oldarr = arr
    var newarr = [];
    if (!asc_or_desc) {
        //升序
        for (var i = 0; i < oldarr.length - 1; i++)
            for (var j = 0; j < oldarr.length - i - 1; j++) {
                if (oldarr[j].usertodistance > oldarr[j + 1].usertodistance) {
                    let temp = oldarr[j + 1];
                    oldarr[j + 1] = oldarr[j];
                    oldarr[j] = temp;
                }
            }
        newarr = oldarr;
        return newarr;
    };
    if (asc_or_desc) {
        //降序
        for (var i = 0; i < oldarr.length - 1; i++)
            for (var j = 0; j < oldarr.length - i - 1; j++) {
                if (oldarr[j].usertodistance < oldarr[j + 1].usertodistance) {
                    let temp = oldarr[j];
                    oldarr[j] = oldarr[j + 1];
                    oldarr[j + 1] = temp;
                }
            }
        newarr = oldarr;
        return newarr;

    };
}

exports.sortarr = sortarr;